# test.exe:mystdio.c usercode.c mystring.c
# 	gcc -o $@ $^
# .PHONY:clean
# clean:
# 	rm -f test.exe log.txt

# 生成静态库 libmystdio.a，依赖 my_stdio.o 和 my_string.o 目标文件
libmystdio.a: mystdio.o mystring.o
	ar -rc $@ $^          
	@echo "build $^ to $@ ... done"  

# 模式规则：所有 .c 源文件编译为对应的 .o 目标文件
%.o: %.c
	@gcc -c $<            
	@echo "compling $< to $@ ... done"  

# 伪目标：清理编译生成的文件
.PHONY: clean
clean:
	@rm -rf *.a *.o stdc*  
	@echo "clean ... done"

# 伪目标：打包头文件和静态库为压缩包
.PHONY: output
output:
	@mkdir -p stdc/include  
	@mkdir -p stdc/lib      
	@cp -f *.h stdc/include 
	@cp -f *.a stdc/lib     
	@tar -czf stdc.tgz stdc 
	@echo "output stdc ... done"



# libmyc.so:mystdio.o mystring.o
# 	gcc -shared -o $@ $^
# mystdio.o:mystdio.c
# 	gcc -fPIC -c $<
# mystring.o:mystring.c 
# 	gcc -fPIC -c $<

# .PHONY:output
# output:
# 	mkdir -p lib/include
# 	mkdir -p lib/mylib
# 	cp -f *.h lib/include
# 	cp -f *.so lib/mylib
# 	tar czf lib.tgz lib
# .PHONY:clean
# clean:
# 	rm -f *.o libmyc.so lib.tgz
# 	rm -rf lib